<?php
header("Content-Type: text/html; charset=UTF-8");
define('IN_ECS', true);
/* 载入语言文件 */

include 'uploadImage.php';
$r=$_GET['r'];
$t=$_GET['t'];
$destination_folder="../../Upload/chat/".$r.'/'; //上传文件路径 
$destination_folder2="Upload/chat/".$r.'/'; //存数据库路径 
$i = new uploadImage($_FILES['filename'],$destination_folder,$t);
$pan=$i->imageStart();

require('../config.php');

$src='photo/'.$r.'/'.$t.'.jpg';

	$user_id=$_REQUEST['user_id'];
	$wb_id=$_REQUEST['wb_id'];
	$fabu_id=$_REQUEST['fabu_id'];
	$to_user_id=$_REQUEST['to_user_id'];
	//$ysrc=$_REQUEST['ysrc'];
	$src=$destination_folder2.$t.'.jpg';
	$csh='<img class="tutu" src="'.$src.'" />';
	//$sql="update ".$oto."_users set userPhoto='{$src}' where userId='{$user_id}'";
	//$result=$db->query($sql);
	$time=date('Y-m-d H:i:s');
	$sql="INSERT INTO ".$oto."_help_chat (`helpId`,`userId`,`acceptUserId`,`content`,`createTime`) VALUES ('$wb_id','$fabu_id','$to_user_id','$csh','$time')";
	$result=$db->query($sql);
	if($result)
	{
		$data[0]['pan']=1;
		$data[0]['msg']=$src;
		//echo json_encode($data);
	}
	else
	{
		$data[0]['pan']=-1;
		$data[0]['msg']="上传失败！";
		//echo json_encode($data);
	}
	//$data[0]['pan']=1;
	//$data[0]['msg']=$src;
	//$data[0]['ysrc']=$ysrc;
	echo json_encode($data);
?>